chrome.runtime.onInstalled.addListener(() => {
    chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true });
});

// 添加标签切换事件监听
chrome.tabs.onActivated.addListener(async (activeInfo) => {
    const tabId = activeInfo.tabId;
    try {
        if(tabId){
            await chrome.sidePanel.getOptions({ tabId });
            await chrome.tabs.sendMessage(tabId, {
                action: "toggleXPathFinder"
            });
        }
    } catch (error) {
        console.log("Target tab not ready yet");
    }
});


